package com.sec.android.app.myfiles.module.local.category;

import android.content.Context;
import android.os.Handler;

import com.sec.android.app.myfiles.log.Log;
import com.sec.android.app.myfiles.module.ContentObservable;
import com.sec.android.app.myfiles.module.abstraction.AbsContentObserverImp;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;

/**
 * Created by daesu83.kim on 2015-07-22.
 */
public class CategoryContentObserverImp extends AbsContentObserverImp {

    private MediaProviderObserver mObserver;

    public CategoryContentObserverImp(Context context, FileRecord record, ContentObservable updater) {
        super(context, record, updater);
    }

    @Override
    public void start() {
        Log.d(this, "Start()");
        if (mObserver == null) {
            if (mContext != null) {
                mObserver = new MediaProviderObserver(mContext, this, new Handler(), mTargetRecord);
                mObserver.start();
            }
        }
    }

    @Override
    public void stop() {
        Log.d(this, "Stop()");
        if (mObserver != null) {
            mObserver.stop();
            mObserver = null;
        }
    }

    @Override
    public void onEvent(int event) {
        Log.d(this, "onEvent()");
        notifyContentChanged(event);
    }
}
